knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
# devtools::install_github("https://github.com/kmcd39/divM.git")
library(sf)
library(dplyr)
# library(divM)
devtools::load_all()
source("../data-raw/rays/setup ray ws.R")

Rays

This package includes functions to generate "rays," stretches of highways that originate outside of a "city center" or other region but run through it.

This markdown gives detail on the data + code used to generate the ray counts.

Data

For the measures here, city centers are defined as the largest census-defined Place within a commuting zone. Hwys are identified using National Highway Planning Network (NHPN), available at: https://catalog.data.gov/dataset/national-highway-planning-network-nhpn

The columns SIGNT1 and SIGN1 in the NHPN data are used respectively to identify highway type (interstate, state route, etc.) and unique highway (i.e., I76, US-3).

Measure Generation

Rays are found by:

  1. Trimming the set of all hwy data to all hwys within and surrounding a Place area
  2. Cleaning/subsetting data based on arguments. This can include:
    • Selecting which hwy types and segments to include
    • Filling holes inside of the Place area
    • Trimming hwy segments based on their length inside the Place and/or filling small gaps between hwy segments
    • See the documentation for ?Count.rays for all options.
  3. Any start-/end- point of any eligible that lies outside of the Place boundary then constitutes a single ray.
    • So if it starts within the Place boundary and ends outside, that is one ray. If it starts and ends outside and spans the boundary, that is two rays.

Rays can be generated most easily with the Count.rays function. This will count the number of rays and bundle a map illustrating them if include.map is true.

Counting Rays Examples

Warnings are generated from sf functions and are not important in this context.

# rays in Philadelphia formed by Interstates, state routes, and US routes:
phl = suppressWarnings( Count.rays(place.geoid = plc.ids[["Philadelphia"]],
           hwys,
           always.include = c("I","U","S")
           ) )
phl$n.rays
phl$map

# rays in Chicago formed by Interstates and all non-NA routes that intersect
# interstates
chi = Count.rays(place.geoid = plc.ids[["Chicago"]],
           hwys,
           always.include = c("I"),
           include.intersecting = T
           )
chi$n.rays
chi$map

# Oklahoma City, with and without Place holes and Highway gaps getting filled
okT = Count.rays(plc.ids["Oklahoma City"]
           ,hwys
           ,always.include = c("I", "U", "S")
           ,remove.holes = T
           ,fill.gaps = T)
okT$n.rays
okT$map

okF = Count.rays(plc.ids["Oklahoma City"]
           ,hwys
           ,always.include = c("I", "U", "S")
           ,remove.holes = F
           ,fill.gaps = F , verbose = F)
okF$n.rays
okF$map


kmcd39/divM documentation built on Oct. 21, 2023, 11:28 p.m.